All Questions
9 questions
5votes
5answers
782views
How can I replace multiple substrings from multiple lines in a file matching a pattern from a different file?
I have a file that contains multiple IP addresses and hostnames, and another file that contains some folders with many IP addresses per line. ip_hostname.txt host1 10.1.1.1 host2 10.2.2.2 host3 10.3.3....
-1votes
1answer
2kviews
Bulk replace multiple variables in multiple files at once
Example: I have 40 different variables like $VAR in 100 .txt files which are located in /home/user/EXAMPLE/. How do I replace all variables in the 100 files? To tell the system what the variables are ...
5votes
4answers
330views
Incrementally Swap Lines Between Two Regex Patterns in a File
I'm trying to do some text processing on a file using a bash script. The goal is to take all of the lines starting with "field:" indented under an 'attribute:' label and swap them with the ...
1vote
1answer
109views
Scripting for text processing: Delete a set of lines only if entire pattern matches
I want to delete a set of lines (globally) only if the entire pattern matches. Pattern Description: Line1:^[#]+ .* Line2:^[[:space:]]*$ Line3:^-[[:space:]]*$ Line4:^[[:space:]]*$ Line5:^[#]+ .*$...
-3votes
1answer
82views
Comparing two fields from two files and printing the common items from the files with the count from each file
I have two files in a below-mentioned way File1 Emp1 Dec10 12Am Emp2 Dec10 2Am Emp3 Dec10 4Am Emp2 Dec10 6Am Emp1 Dec10 8Am File2 Emp1 Dec11 12Pm Emp2 Dec11 2Am Emp1 Dec11 3Am Emp3 Dec11 ...
0votes
1answer
163views
Pattern recognition and summing columns between two csv/excel files
I have two files, in which one has data on each person's start date, increment, promotion and other details, and the other file has their research output over the years. Can a script be written in ...
2votes
2answers
186views
counting occurences of pattern from an input file to match against a huge file
I have a list of colleges in a text file, and in a separate file I have a list of publications with affiliation. I want to write a script, to check, how many times a publication is repeated and to ...
1vote
1answer
904views
pattern file as an input to RS,FS in awk/sed/grep to recognize and add columns
I have a file which has the patterns that I have to find in the given data set and add the numbers in a columns of the data. I want to write a script or use awk/sed/grep to automatically query the ...
26votes
6answers
10kviews
How can I sort a list with major.minor.patch level and sometimes rc correctly?
I have to sort the following list with a shell script and make the latest version appear on the bottom or top. How would I do that with shell tools only? release-5.0.0.rc1 release-5.0.0.rc2 release-5....